home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / bind-contrib.tar.gz / bind-contrib.tar / contrib / misc / netbsd-shlib.shar < prev    next >
Encoding:
Internet Message Format  |  1996-10-25  |  42.2 KB

  1. Path: vixie!pa.dec.com!bind-redist-request
  2. From: matt@ibmoto.com (Matt Ragan)
  3. Newsgroups: local.mail.dns.bind
  4. Subject: Modifications to 4.9.3 shres for NetBSD shared libraries
  5. Date: 20 Sep 1994 15:44:56 -0700
  6. Organization: Vixie Enterprises
  7. Lines: 1119
  8. Sender: daemon@vix.com
  9. Distribution: local
  10. Message-ID: <199409202144.QAA10679@chaos.ibmoto.com>
  11. NNTP-Posting-Host: gw.home.vix.com
  12. X-Received: by gw.home.vix.com id AA21316; Tue, 20 Sep 94 15:44:42 -0700
  13. X-Received: from pobox1.pa.dec.com by inet-gw-1.pa.dec.com (5.65/10Aug94)
  14.     id AA24362; Tue, 20 Sep 94 15:38:02 -0700
  15. X-Received: by pobox1.pa.dec.com; id AA01411; Tue, 20 Sep 94 15:37:34 -0700
  16. X-Received: by pobox1.pa.dec.com; id AA01407; Tue, 20 Sep 94 15:37:32 -0700
  17. X-Received: from relay1.UU.NET by inet-gw-2.pa.dec.com (5.65/10Aug94)
  18.     id AA21672; Tue, 20 Sep 94 15:31:16 -0700
  19. X-Received: by relay1.UU.NET 
  20.     id QQxifo10749; Tue, 20 Sep 1994 18:09:47 -0400
  21. X-Received: from apple.com by relay1.UU.NET with SMTP 
  22.     id QQxifo10709; Tue, 20 Sep 1994 18:09:33 -0400
  23. X-Received: from [129.38.12.8] by apple.com with SMTP (5.61/8-Oct-1993-eef)
  24.     id AA20809; Tue, 20 Sep 94 14:47:10 -0700
  25.     for bind@uunet.uu.net
  26. X-Received: (from matt@localhost) by chaos.ibmoto.com (8.6.9/8.6.9) id QAA10679 for bind@uunet.uu.net; Tue, 20 Sep 1994 16:44:10 -0500
  27. X-To: bind@uunet.uu.net
  28. X-Mailer: ELM [version 2.4 PL23]
  29. X-Mime-Version: 1.0
  30. X-Content-Type: text/plain; charset=US-ASCII
  31. X-Content-Transfer-Encoding: 7bit
  32. X-Content-Length: 41677     
  33.  
  34. Here is a shar file that contains a new shres directory and a diff to the
  35. main Makefile to add support for automatically building shared libraries
  36. on NetBSD for BIND 4.9.3.  The Makefile, 'makeshlib' script and installation
  37. instructions in 'shres' are capable of building shared libraries for both
  38. SunOS 4.x and for NetBSD 1.x (on the SPARC at least - I don't have a PC
  39. available to test out the Intel version, so it someone would like to try
  40. it and let me know if it works, or what changes need to be made, I'd be
  41. most appreciative)
  42.  
  43.  
  44. Here's the short and simple on installing it:
  45.  
  46. Move your shres directory to a different name, such as shres.old.
  47.  
  48. Unshar the file at the bottom of this message
  49.  
  50. Run 'patch -p Makefile <Makefile.diff' to add four lines to the Makefile
  51. so it will build the shres/libresolv_pic.a library.
  52.  
  53. Follow the installation instructions in shres/INSTALL.NetBSD.
  54.  
  55.  
  56. Please contact me if you have any problems, questions, or suggestions.
  57. -- 
  58. --------------------------------------------------------------------------
  59. Matt Ragan  (matt@ibmoto.com)  Motorola/IBM Somerset PowerPC Design Center
  60. Network Administrator          Systems/Network Engineering  (512) 795-7298
  61. 9737 Great Hills Trail         Austin, Tx  78759        FAX (512) 795-7519
  62. --------------------------------------------------------------------------
  63.  
  64. ----- 8< --- Cut here --- >8 -----
  65. # This is a shell archive.  Save it in a file, remove anything before
  66. # this line, and then unpack it by entering "sh file".  Note, it may
  67. # create directories; files and directories will be owned by you and
  68. # have default permissions.
  69. #
  70. # This archive contains:
  71. #
  72. #    shres
  73. #    shres/INSTALL
  74. #    shres/INSTALL.NetBSD
  75. #    shres/ISSUES
  76. #    shres/Makefile
  77. #    shres/README.NetBSD
  78. #    shres/lorder-sparc.sed
  79. #    shres/makeshlib
  80. #    shres/shlibname.awk
  81. #    Makefile.diff
  82. #
  83. echo c - shres
  84. mkdir shres > /dev/null 2>&1
  85. echo x - shres/INSTALL
  86. sed 's/^X//' >shres/INSTALL << 'END-of-shres/INSTALL'
  87. XInstalling BIND 4.9.3 resolver code in SunOS 4.1.x shared libraries
  88. X===================================================================
  89. X
  90. X$Id: netbsd-shlib.shar,v 8.2 1996/10/25 17:07:58 vixie Exp $
  91. X
  92. Xby Chris Davis <ckd@kei.com>
  93. X
  94. Xbased on code and documentation by:
  95. X  Paul Balyoz <pab@naucse.cse.nau.edu>
  96. X  Piete Brooks <pb@cl.cam.ac.uk>
  97. X  Dave Morrison <drmorris@mit.edu>
  98. X  Hal Pomeranz <pomeranz@nas.nasa.gov>
  99. Xand probably others (apologies if I've forgotten you).
  100. X
  101. XNote that if you wish to modify this process, you should read and
  102. Xunderstand the file ISSUES in this directory.
  103. X
  104. X1.  Get and unpack a copy of BIND 4.9.3.  (This document is from that
  105. X    distribution, as shres/INSTALL.)  BIND's home site is
  106. X    gatekeeper.dec.com, and it lives in /pub/misc/vixie.
  107. X
  108. X    In the remainder of this document, $BINDSRC represents the directory
  109. X    you unpacked the BIND distribution into.
  110. X
  111. X2.  Configure it to your tastes by editing $BINDSRC/conf/options.h, using
  112. X    $BINDSRC/OPTIONS as a guide to the available choices.  SUNSECURITY
  113. X    must be on (and will be turned on automatically on Suns).  Not all of
  114. X    the options affect the resolver library, but you probably want the new
  115. X    named as well (the one Sun supplies is really, really old).
  116. X
  117. X3.  (Optional) Use "make DST=sun4.b links" to create a shadow source tree
  118. X    for the Sun4 architecture (see $BINDSRC/README for details).  This is
  119. X    particularly useful if you are building for more than one architecture
  120. X    or operating system (like, say, SunOS 4.1.x and Solaris 2.x).  If you
  121. X    do this, cd into the new build directory ("cd sun4.b", for example).
  122. X
  123. X4.  Uncomment the appropriate lines in $BINDSRC/sun4.b/Makefile (or
  124. X    $BINDSRC/Makefile if you didn't do step 3, shame shame) for SunOS 4.
  125. X    To build a shared library, uncomment the lines just after the one
  126. X    labeled "uncomment next line to build a shared library version of
  127. X    libresolv", in the SunOS 4.x section.  If you have gcc, use it, as it
  128. X    can share the read-only data (see $BINDSRC/shres/ISSUES for more
  129. X    details).
  130. X
  131. X    Note that there are some "common" lines in the Makefile that you will
  132. X    need to uncomment for SunOS 4 in addition to the ones specifically for
  133. X    SunOS 4; don't forget to uncomment those as well.
  134. X
  135. X5.  (Optional) Add $BINDSRC/bin to your path, and "make depend".
  136. X
  137. X6.  Type "make" to build named, the tools, the "normal" libresolv, and the
  138. X    position-independent code ("pic") libresolv.
  139. X
  140. X7.  Install the appropriate "jumbo libc patch" for your SunOS version, if
  141. X    you haven't already.  Among other things, this includes fixes for some
  142. X    bugs in the shared library building process.
  143. X
  144. X    At the time of this writing, the patch numbers and latest revisions of
  145. X    the "international" versions of these patches were:
  146. X
  147. X      4.1.3:    100891-10
  148. X      4.1.3_U1: 101558-02
  149. X
  150. X    Note that "international" means "has not installed the extra-cost 'US
  151. X    Encryption Kit'", so most sites, even in the US, will need these
  152. X    versions.  If you have installed the "US Encryption Kit" you will need
  153. X    to get the domestic versions.
  154. X
  155. X    As "recommended" patches, these patches are available for anonymous
  156. X    ftp to all Sun customers, even those without support contracts, from
  157. X    sunsolve1.sun.com in the /pub/patches directory.
  158. X
  159. XPerform the following steps to integrate the shareable resolver library
  160. Xcode (libresolv_pic.a) into the shared libc (for both BSD and SysV
  161. Xuniverses).  If you use the $BINDSRC/shres/makeshlib script, steps 8-16
  162. Xwill be done for you; in that case, you may want to skip ahead to step 17.
  163. X
  164. XThe makeshlib script does minimal error checking and is mostly a quick &
  165. Xdirty convenience for people tired of typing commands.
  166. X
  167. XNote that some or all of these steps may need to be done as root.  You
  168. Xshould read the makeshlib script carefully before running it as root.
  169. X
  170. XThe makeshlib script is not executable by default.  You may wish to use
  171. X"sh -x shres/makeshlib" to view the commands as they are executed as a
  172. Xprogress indicator.
  173. X
  174. X8.  Move into the shared-lib area and make a temporary directory:
  175. X
  176. X      cd /usr/lib/shlib.etc
  177. X      mkdir tmp
  178. X
  179. X9.  Move into this new directory, extract the pic (position independent
  180. X    code) object files from libc_pic.a and remove the SYMDEF file.  The
  181. X    renaming (mv commands) is done because the "ar" command truncates
  182. X    names to 16 characters.
  183. X
  184. X      cd tmp
  185. X      ar x ../libc_pic.a
  186. X      rm __.SYMDEF
  187. X      mv rpc_dtablesize. rpc_dtablesize.o
  188. X      mv rpc_commondata. rpc_commondata.o
  189. X      mv xccs.multibyte. xccs.multibyte.o
  190. X
  191. X10. Extract the shareable libresolv_pic.a into this target directory.  This
  192. X    will replace Sun's inet_addr.o, which is ok, this one is better.  It
  193. X    will also replace Sun's getnetent.o, which is ok, as long as you have
  194. X    DNS entries for your networks (as in RFC 1101).  Make sure that Sun's
  195. X    mktemp.o and strpbrk.o don't get stomped; you need to use Sun's.
  196. X
  197. X      ar x $BINDSRC/shres/libresolv_pic.a
  198. X      rm __.SYMDEF
  199. X
  200. X11. Make sure the old host resolver is not still lying around:
  201. X
  202. X       rm gethostent.o
  203. X
  204. X    (ignore error "rm: gethostent.o nonexistent" if you see it.)
  205. X
  206. X12. Go back up to the shared library building directory and duplicate the
  207. X    list of object files to use:
  208. X
  209. X      cd ..
  210. X      cp lorder-sparc lorder-sparc.orig
  211. X
  212. X13.  Edit this object file list and make the following modifications if
  213. X     they haven't already been done before to this file:
  214. X
  215. X             remove: gethostent.o
  216. X             add:    gethnamaddr.o
  217. X                     herror.o
  218. X                     sethostent.o
  219. X                     res_query.o
  220. X                     res_mkquery.o
  221. X                     res_send.o
  222. X                     res_debug.o
  223. X                     res_comp.o
  224. X                     res_init.o
  225. X                     getnetnamadr.o
  226. X                     getnetbyname.o
  227. X                     getnetbyaddr.o
  228. X                     strerror.o
  229. X
  230. X     If you don't want the getnet* routines (some sites want to use yp for
  231. X     getting networks), don't add the getnet* lines.  It isn't really
  232. X     kosher to hack the lorder-sparc file like this, but it isn't
  233. X     deadly either.  Other orderings may have different performance
  234. X     effects (could be better, could be worse...).
  235. X
  236. X     The easiest way to do this is to apply (using the 'patch' program)
  237. X     the patch file $BINDSRC/shres/sun-lorder-sparc.patches.
  238. X
  239. X14.  The Makefile in shlib.etc for building shared libraries has one
  240. X     problem when you run it as the super user if you don't have '.' in
  241. X     your path (and you shouldn't...).  So edit it and modify the
  242. X     definition of "OBJSORT" to read:
  243. X
  244. X       OBJSORT=./objsort
  245. X
  246. X     If you are using the SunOS 4.1.x unpatched shlib.etc, change the
  247. X     lines (there are two) in the Makefile which read
  248. X
  249. X       ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
  250. X
  251. X     to read
  252. X
  253. X       ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
  254. X
  255. X     The patched shlib.etc for 4.1.3 already has this fixed, but the
  256. X     patched shlib.etc for 4.1.3_U1 does not.  (Why?  I don't know...)
  257. X
  258. X     The easiest way to do this is to apply (using the 'patch' program)
  259. X     the patch file $BINDSRC/shres/sun-Makefile.patches.  If you have the
  260. X     4.1.3 version of the Makefile, the second chunk will fail; this can
  261. X     safely be ignored.
  262. X
  263. X15.  Now we can finally build the shared library.  Type:
  264. X       make libc.so
  265. X
  266. X     What kind of errors might you get?  Here's a couple:
  267. X
  268. X       a. It blows up on one of the .o files in tmp, saying that the
  269. X      object file is in an inconsistent state.
  270. X
  271. X          SOLUTION: start over; you did something wrong when you compiled
  272. X      libresolv_pic.a in step 4, above.  Make SURE you're using the
  273. X      libresolv_pic.a that was built in $BINDSRC/shres, and not the
  274. X      "normal" libresolv.a built in $BINDSRC/res.
  275. X
  276. X       b. It lists hundreds of error lines about offsets or addresses
  277. X      being wrong in all your resolver .o files.
  278. X
  279. X          SOLUTION: start over; you needed to specify "-pic" or "-fpic" to
  280. X      the C compiler when building shres/libresolv_pic.a.  Make sure
  281. X      you're using libresolv_pic.a, and make sure that SHCC and PIC
  282. X      were properly defined in $BINDSRC/Makefile.
  283. X
  284. X16.  To build the System V shared libc, repeat steps 8-11, using
  285. X     'libcs5_pic.a' instead of 'libc_pic.a', then 'make libcs5.so'.
  286. X
  287. XIf you used makeshlib, you should now 'cd /usr/lib/shlib.etc' for the
  288. Xfollowing tests. You will also have a symlink "tmp" and two directories
  289. X"tmp.s5" and "tmp.ucb" in this directory, all three of which can be
  290. Xdeleted.
  291. X
  292. X17.  If all goes well, you now have a "libc.so.x.y.z" in this directory
  293. X     (two, if you rebuilt the SysV shared library as well; the BSD one is
  294. X     libc.so.1.y.z, while the SysV one is libc.so.2.y.z).  Test it (or
  295. X     them) out before installing it (or them) systemwide!  You can do this
  296. X     by pointing the LD_LIBRARY_PATH environment variable to the current
  297. X     directory, then trying various networking commands.
  298. X
  299. X     In csh or tcsh:
  300. X       setenv LD_LIBRARY_PATH `pwd`
  301. X       ftp another.host.com
  302. X       telnet someone.else.ca
  303. X       unsetenv LD_LIBRARY_PATH
  304. X
  305. X     ping (or any other setuid/setgid program) will not work if you test
  306. X     it this way, because LD_LIBRARY_PATH is ignored for security reasons.
  307. X
  308. X     Make sure you have a valid /etc/resolv.conf, or it will not appear to
  309. X     work.  If you have been using DNS via NIS in the past, you might not
  310. X     have a resolv.conf file on the clients.
  311. X
  312. X     If anything in the library fails, you need to start section B over
  313. X     again.  Maybe you forgot to use Sun's versions of mktemp.o and
  314. X     strpbrk.o; things just won't work with BIND's new versions of these
  315. X     files.
  316. X
  317. X18.  When you are sure it's working OK, you can install it into the system
  318. X     library directory (you will need to be superuser to do this):
  319. X
  320. X       su
  321. X       cd /usr/lib/shlib.etc
  322. X       cp libc.so.x.y.z /usr/lib
  323. X       chmod 755 /usr/lib/libc.so.x.y.z
  324. X       # for sysv shared library
  325. X       cp libc.so.x.y.z /usr/5lib
  326. X       chmod 755 /usr/5lib/libc.so.x.y.z
  327. X       # for both
  328. X       ldconfig
  329. X
  330. X     Next you need to install the shared archive, which contains
  331. X     initialized global data.  If you skip this step, executables compiled
  332. X     on your machine since the new library was installed will not contain
  333. X     that data.  They still will be able to run (which is probably why
  334. X     this step has been missing from both the Internet and *Sun*
  335. X     instructions for years), as the data is replicated in the shared
  336. X     object.  A few preliminary tests indicate missing this step can
  337. X     marginally slow down processes, although it necessarily a depends on
  338. X     the program and the machine in question.  For more details on this,
  339. X     see $BINDSRC/shres/ISSUES.
  340. X
  341. X     The numbers x, y, and z must match the numbers in the shared object
  342. X     above.
  343. X
  344. X       cd /usr/lib
  345. X       cp libc.sa.x.y libc.sa.x.y.z
  346. X       ranlib libc.sa.x.y.z
  347. X       cd /usr/5lib
  348. X       cp libc.sa.x.y libc.sa.x.y.z
  349. X       ranlib libc.sa.x.y.z
  350. X
  351. X19.  You can prove that you're using the new library now, by watching the
  352. X     output of something like:
  353. X
  354. X       trace date
  355. X
  356. X     Look for the open() of libc.so.* and note the version number.
  357. X
  358. X     The latest BIND resolver is now installed in your system's shared C
  359. X     library.
  360. X
  361. X20.  Once you are fully confident of your new library, reboot your
  362. X     machine.  Until you do, running processes will continue to use the
  363. X     old shared library.
  364. X
  365. XYou may also want to modify the unshared system C library /usr/lib/libc.a;
  366. Xsee the item "Modifying the static libc" in shres/ISSUES for discussion of
  367. Xhow (and why) to do this.
  368. X
  369. END-of-shres/INSTALL
  370. echo x - shres/INSTALL.NetBSD
  371. sed 's/^X//' >shres/INSTALL.NetBSD << 'END-of-shres/INSTALL.NetBSD'
  372. XInstalling BIND 4.9.3 resolver code in NetBSD 1.x shared libraries
  373. X===================================================================
  374. X
  375. Xmodified for NetBSD by Matt Ragan <matt@ibmoto.com>
  376. X
  377. Xbased directly on documentation for installing SunOS shared libraries
  378. Xby Chris Davis <ckd@kei.com>
  379. X
  380. Xbased on code and documentation by:
  381. X  Paul Balyoz <pab@naucse.cse.nau.edu>
  382. X  Piete Brooks <pb@cl.cam.ac.uk>
  383. X  Dave Morrison <drmorris@mit.edu>
  384. X  Hal Pomeranz <pomeranz@nas.nasa.gov>
  385. Xand probably others (apologies if I've forgotten you).
  386. X
  387. XNote that if you wish to modify this process, you should read and
  388. Xunderstand the file ISSUES in this directory.
  389. X
  390. X1.  Get and unpack a copy of BIND 4.9.3.  (This document is from that
  391. X    distribution, as shres/INSTALL.)  BIND's home site is
  392. X    gatekeeper.dec.com, and it lives in /pub/misc/vixie.
  393. X
  394. X    In the remainder of this document, $BINDSRC represents the directory
  395. X    you unpacked the BIND distribution into.
  396. X
  397. X2.  Configure it to your tastes by editing $BINDSRC/conf/options.h, using
  398. X    $BINDSRC/OPTIONS as a guide to the available choices.  SUNSECURITY
  399. X    must be on (and will be turned on automatically on Suns).  Not all of
  400. X    the options affect the resolver library, but you probably want the new
  401. X    named as well.  The one supplied with NetBSD 1.0 is from BIND 4.8.3.
  402. X
  403. X3.  (Optional) Use "make DST=NetBSD links" to create a shadow source tree
  404. X    for the NetBSD architecture (see $BINDSRC/README for details).  This is
  405. X    particularly useful if you are building for more than one architecture
  406. X    or operating system (like, say, SunOS 4.1.x and Solaris 2.x).  If you
  407. X    do this, cd into the new build directory ("cd NetBSD", for example).
  408. X
  409. X4.  Uncomment the appropriate lines in $BINDSRC/NetBSD/Makefile (or
  410. X    $BINDSRC/Makefile if you didn't do step 3, shame shame) for NetBSD 1.x.
  411. X    To build a shared library, uncomment the lines just after the one
  412. X    labeled "uncomment next line to build a shared library version of
  413. X    libresolv", in the NetBSD section.
  414. X
  415. X5.  (Optional) run "make depend".
  416. X
  417. X6.  Type "make" to build named, the tools, the "normal" libresolv, and the
  418. X    position-independent code ("pic") libresolv.
  419. X
  420. X7.  Perform the following steps to integrate the shareable resolver library
  421. X    code (libresolv_pic.a) into the shared libc.  If you use the
  422. X    $BINDSRC/shres/makeshlib script, steps 8-14 will be done for you;
  423. X    in that case, you may want to skip ahead to step 17.
  424. X
  425. X    The makeshlib script does minimal error checking and is mostly a quick &
  426. X    dirty convenience for people tired of typing commands.
  427. X
  428. X    Note that some or all of these steps may need to be done as root.  You
  429. X    should read the makeshlib script carefully before running it as root.
  430. X
  431. X    The makeshlib script is not executable by default.  You may wish to use
  432. X    "sh -x shres/makeshlib" to view the commands as they are executed as a
  433. X    progress indicator.
  434. X
  435. X8.  Make a temporary directory underneath the shlib directory
  436. X
  437. X      mkdir tmp
  438. X
  439. X9.  Move into this new directory, extract the pic (position independent
  440. X    code) object files from libc_pic.a and remove the SYMDEF file.
  441. X
  442. X      cd tmp
  443. X      ar x /usr/lib/libc_pic.a
  444. X      rm __.SYMDEF
  445. X
  446. X10. The BIND 4.9.3 resolver will replace getnet*.o, which is ok, as long
  447. X    as you have DNS entries for your networks (as in RFC 1101).  If you do
  448. X    not want to use the BIND 4.9.3 getnet*.o, delete them out of the
  449. X    archive.
  450. X
  451. X        ar d ../libresolv_pic.a getnetbyaddr.o getnetbyname.o \
  452. X            getnetent.o getnetnamadr.o
  453. X        ranlib ../libresolv_pic.a
  454. X
  455. X11. Extract the shareable libresolv_pic.a into this target directory.  It
  456. X    will replace getnetent.o, which is ok, as long as you have DNS entries
  457. X    for your networks (as in RFC 1101).
  458. X
  459. X      ar x ../libresolv_pic.a
  460. X      rm __.SYMDEF
  461. X
  462. X12. Make sure the old host resolver is not still lying around:
  463. X
  464. X       rm gethostnamadr.o
  465. X
  466. X    (ignore error "rm: gethostnamadr.o nonexistent" if you see it.)
  467. X
  468. X13. Go back up to the shared library building directory and create the
  469. X    list of object files to use:
  470. X
  471. X      cd ..
  472. X      lorder tmp/*.so tmp/*.o | tsort > lorder.list
  473. X
  474. X    (ignore any nm: or lorder: warning/errors)
  475. X
  476. X14.    Use this command to make the new shared library:
  477. X
  478. X    ld -o libc.so.`/bin/ls /usr/lib/libc.so.* | awk -f shlibname.awk` \
  479. X       -Bshareable -Bforcearchive `cat lorder.list`
  480. X
  481. X     What kind of errors might you get?  Here's a couple:
  482. X
  483. X       a. It blows up on one of the .o files in tmp, saying that the
  484. X      object file is in an inconsistent state.
  485. X
  486. X          SOLUTION: start over; you did something wrong when you compiled
  487. X      libresolv_pic.a in step 4, above.  Make SURE you're using the
  488. X      libresolv_pic.a that was built in $BINDSRC/shres, and not the
  489. X      "normal" libresolv.a built in $BINDSRC/res.
  490. X
  491. X       b. It lists hundreds of error lines about offsets or addresses
  492. X      being wrong in all your resolver .o files.
  493. X
  494. X          SOLUTION: start over; you needed to specify "-pic" or "-fpic" to
  495. X      the C compiler when building shres/libresolv_pic.a.  Make sure
  496. X      you're using libresolv_pic.a, and make sure that SHCC and PIC
  497. X      were properly defined in $BINDSRC/Makefile.
  498. X
  499. XIf you used makeshlib, you should make sure you are in $BINDSRC/shres for
  500. Xthe following tests. You will also have a directory "ucbtmp" which can be
  501. Xdeleted.
  502. X
  503. X15.  If all goes well, you now have a "libc.so.x.y.z" in this directory
  504. X     libc.so.1.y.z, while the SysV one is libc.so.2.y.z).  Test it out
  505. X     before installing it systemwide!  You can do this by pointing the
  506. X     LD_LIBRARY_PATH environment variable to the current directory, then
  507. X     trying various networking commands.
  508. X
  509. X     In csh or tcsh:
  510. X       setenv LD_LIBRARY_PATH `pwd`
  511. X       ftp another.host.com
  512. X       telnet someone.else.ca
  513. X       unsetenv LD_LIBRARY_PATH
  514. X
  515. X     ping (or any other setuid/setgid program) will not work if you test
  516. X     it this way, because LD_LIBRARY_PATH is ignored for security reasons.
  517. X
  518. X     Make sure you have a valid /etc/resolv.conf, or it will not appear to
  519. X     work.  If you have been using DNS via NIS in the past, you might not
  520. X     have a resolv.conf file on the clients.
  521. X
  522. X16.  When you are sure it's working OK, you can install it into the system
  523. X     library directory (you will need to be superuser to do this):
  524. X
  525. X       su
  526. X       cp libc.so.x.y.z /usr/lib
  527. X       chmod 444 /usr/lib/libc.so.x.y.z
  528. X       ldconfig
  529. X
  530. X17.  You can prove that you're using the new library now, by watching the
  531. X     output of something like:
  532. X
  533. X       trace date
  534. X
  535. X     Look for the open() of libc.so.* and note the version number.
  536. X
  537. X     The latest BIND resolver is now installed in your system's shared C
  538. X     library.
  539. X
  540. X18.  Once you are fully confident of your new library, reboot your
  541. X     machine.  Until you do, running processes will continue to use the
  542. X     old shared library.
  543. X
  544. XYou may also want to modify the unshared system C library /usr/lib/libc.a;
  545. Xsee the item "Modifying the static libc" in shres/ISSUES for discussion of
  546. Xhow (and why) to do this.
  547. X
  548. END-of-shres/INSTALL.NetBSD
  549. echo x - shres/ISSUES
  550. sed 's/^X//' >shres/ISSUES << 'END-of-shres/ISSUES'
  551. XExpanded and updated for BIND 4.9.3 by Chris Davis <ckd@kei.com>
  552. X                                       1994: 6/6, 6/28, 7/6, 7/11
  553. XOriginally by  Dave Morrison <drmorris@mit.edu>, 2/3/94
  554. X
  555. XChanges to the shared library setup have lots of little pitfalls and
  556. Xmines.  This is an attempt to map the minefield, for those who feel
  557. Xthey've noticed something that they think should be done another way.
  558. X
  559. X
  560. X* What's shared, what's static
  561. X
  562. XThe purpose of these modifications to Sun's libc.so is to provide DNS
  563. Xlookup for gethostby* and if you desire, getnetby* (this requires
  564. Xinstalling RFC 1101 network entries in the DNS).  This involves replacing
  565. Xthe following SunOS libc routines.
  566. X
  567. X    gethostbyname            getnetbyname
  568. X    gethostbyaddr            getnetbyaddr
  569. X    gethostent            getnetent
  570. X    sethostent            setnetent
  571. X    endhostent            endnetent
  572. X
  573. XThe routines use the res_* routines from the resolv library to get their
  574. Xinformation from DNS.  Because it is most convenient, all these objects
  575. Xare linked into the shared library, meaning they are linkable without
  576. Xusing -lresolv.  Full details are given below, and unless you want to get
  577. Xinto the nitty gritty, obey the following rule.
  578. X
  579. XAnything which uses -lresolv routines other than the stock OS routines
  580. Xabove should link using -lresolv.
  581. X
  582. XThe symptom of not obeying this rule is finding that _res is unresolved at
  583. Xlink time.
  584. X
  585. X
  586. X* Modifying the static libc
  587. X
  588. XThe 4.9.3 libresolv uses two routines that are not in Sun's shipped libc
  589. X(inet_aton and strerror).  The BIND 4.9.3 shared library install procedure
  590. Xmerges the compatibility code for these routines into libc.so, but does
  591. Xnot modify libc.a, nor does it include these routines into the unshareable
  592. Xlibresolv.a.  This means code that is statically linked (cc -Bstatic or
  593. Xgcc -static) that uses -lresolv will fail to link unless also linked with
  594. Xthe compatibility library (lib44bsd.a).  Typical culprits are emacs and
  595. XBerkeley sendmail 8.6.x, since they're among the few things that are often
  596. Xlinked statically.
  597. X
  598. XSolutions for this dilemma include (but are probably not limited to) the
  599. Xfollowing:
  600. X
  601. X  - use 'ar' to integrate the needed compatibility code in libc.a
  602. X
  603. X  - use 'ar' to integrate the needed compatibility code in libresolv.a
  604. X
  605. X  - always link programs dynamically, even when using -lresolv
  606. X
  607. X  - link with -l44bsd when statically linking and using -lresolv
  608. X
  609. XThe needed compatibility modules are compat/lib/inet_addr.o and
  610. Xcompat/lib/strerror.o.  Note that inet_addr.o, if integrated into libc.a,
  611. Xwill replace Sun's supplied one, but as with the shared library code
  612. X"that's ok, this one is better".
  613. X
  614. XMy personal solution was to link them into libc.a, in order to have as few
  615. Xdifferences between statically and dynamically linked programs as possible.
  616. X
  617. XTo do this, first make a copy of libc.a (call it libcnew.a).
  618. X
  619. XThen, from the top of the BIND build tree (i.e. $BINDSRC/sun4.b if you did
  620. X"make links"):
  621. X
  622. X  ar rv /usr/lib/libcnew.a compat/lib/inet_addr.o compat/lib/strerror.o
  623. X
  624. X(you should see something like
  625. X  r - compat/lib/inet_addr.o
  626. X  a - compat/lib/strerror.o
  627. Xas the output from ar)
  628. X
  629. X  ranlib /usr/lib/libcnew.a
  630. X
  631. XMake sure nobody is using the static libc for anything, then
  632. X
  633. X  cd /usr/lib
  634. X  mv libc.a libc.a.old && mv libcnew.a libc.a
  635. X
  636. X
  637. X* Compiling with gcc
  638. X
  639. XCompiling resolv with gcc is highly preferable as it understands the
  640. Xconcept of making read only data shared.  Sun's 4.1.3 cc doesn't (simply
  641. Xto make read-only strings shared takes some nasty effort).
  642. X
  643. XCurrently (4.9.3 resolv and gcc 2.5.8), the resolv library uses does not
  644. Xcreate any special gcc references.  Specifically, there are no unresolved
  645. Xreferences in the resolv objects, that are present in libgcc.a.  This
  646. Xmeans that even if you compile with gcc, the objects created may be linked
  647. Xwith any compiler.  All is cool, use gcc.
  648. X
  649. XSHOULD THIS CHANGE (in a new release of gcc, or resolv - not likely to
  650. Xchange, but possible), you can still use gcc and create objects usable by
  651. Xany compiler.  You will need to add libgcc.a to the shared library link
  652. Xline (before -ldl).
  653. X
  654. X
  655. X* global variable collision
  656. X
  657. XThe global variable _res is particularly troublesome.  Any executables
  658. Xwhich were compiled with -lresolv before the shared library was installed
  659. Xhas in it _res staticly compiled in as a global data structure.
  660. XUnfortunately, the resolv library in 4.9.3 BIND has a global variable
  661. X_res, and it is defined slightly differently.  At run time, when the
  662. Xshared libraries are loaded up, some linking is done by ld.so.  The
  663. Xruntime linker notices that _res is statically defined and does not link
  664. Xin the dynamic version.  This means that if the shared libc resolver code
  665. Xever gets called from this executable, the _res defined there would
  666. Xoverwrite the static version.  Since the static version is a smaller data
  667. Xstructure, this could overwrite bits of memory.  Not good.  It turns out
  668. Xthe worst case is not a likely scenario, but I'd rather be safe then
  669. Xsorry.
  670. X
  671. XThis is why shres/Makefile does -D_res=_res_shlib.  The collision is
  672. Xremoved.  This means that _res is not accessible as a global variable in
  673. Xthe shared libc library.  To compile a program which accesses _res
  674. Xdirectly, libresolv must linked in statically.
  675. X
  676. XThis would not be a problem if you could recompile any code which used
  677. X_res.  This would mean recompiling some of SunOS and perhaps other vendor
  678. Xcode if you've obtained additional software.  Since people don't generally
  679. Xhave the source to everything on the machine, this isn't a viable option
  680. Xexcept for Sun and miscellaneous wizards.
  681. X
  682. XNote that because of this workaround, you cannot use libresolv_pic.a as
  683. X/usr/lib/libresolv.a, which would make things much simpler.  (If you try,
  684. Xprograms linked with -lresolv won't find _res, as it will be named
  685. X_res_shlib.)
  686. X
  687. X
  688. X* Having named and tools linked with a shared libc.
  689. X
  690. XIt is very tempting (and almost doable) to compile the entire BIND
  691. Xdistribution with a resolv in a shared libc.  There are dangers associated
  692. Xwith doing this.  First, there's the global variable collision problem
  693. Xmentioned above.  Second, there's a problem of maintaining the the shared
  694. Xlibrary version control.
  695. X
  696. XPeople have a tendency to copy tools like dig or the named server from
  697. Xmachine to machine.  If the new shared library (the one with *this*
  698. Xdistributions resolv) is not present on the machines to which these
  699. Xgoodies are copied TO, the user will be getting SUN'S copy of resolv.
  700. XThis could cause you to lose most heinously, and you will spend DAYS if
  701. Xnot WEEKS trying to figure out what the problem is.  It's debatable if
  702. Xthere's even a performance improvement by doing the sharing.  Compare that
  703. Xto the debugging and frustration time you are going to spend.
  704. X
  705. XYou also will need to replace libc everywhere when a new release when new
  706. Xreleases come out.  This isn't as big an issue for a production release of
  707. Xbind, but for the alpha test team, it means a few less things to worry
  708. Xabout, when there is already plenty to worry about.
  709. X
  710. XAgain, if you could recompile everything, there wouldn't be a problem.
  711. XVendors should release the tools and server shared, as they already have
  712. Xthe assurance that there is a standard libc, and users may want to handle
  713. Xsome problem routines by relinking the shared library.
  714. X
  715. X
  716. X* shared archives
  717. X
  718. XIn addition to a shared object (the libc.so files) which contain the
  719. Xexecutable libc code, there is also a shared archive (the libc.sa files).
  720. XThe shared archive contains global initialized data.  When a program is
  721. Xlinked, if it accesses any of this global initialized data, that data is
  722. Xincluded from the shared archive in the final executable.  Some examples
  723. Xinclude errno (intialzed to zero), the ctype.h tables, sys_errlist, and
  724. X_iob for stdio.
  725. X
  726. XIf this data is not accessible from a shared archive, but is accessible
  727. Xfrom the shared object (e.g. no libc.sa.x.y.z exists for libc.so.x.y.z),
  728. Xthe shared object copy will be used, but not linked into the executable.
  729. XThis results in a performance hit for executables which use that data.
  730. XSun's documentation claims this to be possibly degrading to the system as
  731. Xa whole on a heavily used library.  I have yet to observe anything besides
  732. Xa slight (max 10%) performance hit.
  733. X
  734. XThis is why it is important to copy+ranlib the old libc.sa.a.b.c, when
  735. Xcreating a new libc.so.x.y.z.  Sun's instructions in building a new shared
  736. Xlibc (shlib.etc package or patch) neglect to mention this.
  737. X
  738. XThere are 5 instances of global initialized data in -lresolv.  They are
  739. X_res (renamed to _res_shlib), _res_resultcodes, _res_opcodes, h_errlist,
  740. Xand h_nerr.  In principle, they should be added to libc.sa.x.y.z.
  741. XHowever, long as they are never referenced, it does not matter that they
  742. Xare not there.  Programs which use these variables should link with
  743. X-lresolv to get the static version, and the problem is solved.
  744. X
  745. XThe reason for not including them in the shared archive, is that there
  746. Xis a potential problem in that if this global data ever changed, as it
  747. Xmight in a future bind release, the MAJOR version of the library should
  748. Xchange.  By using the static versions with -lresolv, you allow yourself
  749. Xthe option to upgrade the -lresolv code without major fuss.
  750. X
  751. XUpdate: in 4.9.3, the resolver library no longer uses initialized static
  752. Xdata, so this should never be a problem again.  (You should still copy and
  753. Xre-ranlib the Sun-supplied libc.sa, however.)
  754. X
  755. X
  756. X* shared library revision numbers
  757. X
  758. XTechnically, the shared library changes are sufficient enough to warrent a
  759. Xminor revision change.  On SunOS 4.1.3, this would mean the shared library
  760. Xshould be numbered libc.so.1.9.  However, Sun has already used this for
  761. X4.1.3_U1.  If you upgrade, you will suddenly have two libc.so.1.9's.
  762. XPrograms would be compiled to use "libc.so.1.9" and would be no
  763. Xdistinction between those which want to use the SunOS libc.so.1.9 and
  764. Xthose which want the locally compiled libc.so.1.9.  At this point, the
  765. Xlocally compiled libc.so.1.9 should really be 1.10, and you have to
  766. Xrecompile everything you originally compiled, anyway.
  767. X
  768. XSo, for 4.1.3, stick with libc.so.1.8.x++; for 4.1.3_U1, libc.so.1.9.x++.
  769. XJust be aware that if you compile on a machine with this new shared
  770. Xlibrary, and you use the res_ routines directly without -lresolv (uncool,
  771. Xsee above) you will not be able to take it to a previous stock SunOS
  772. Xwithout a few problems.
  773. END-of-shres/ISSUES
  774. echo x - shres/Makefile
  775. sed 's/^X//' >shres/Makefile << 'END-of-shres/Makefile'
  776. XCFLAGS=    ${CDEBUG} -I${INCL} -I${COMPINCL} ${DEFS} ${LOCDEFS}
  777. XLOCDEFS= -DUSE_OPTIONS_H
  778. XSRCS=    herror.c res_debug.c \
  779. X    res_comp.c res_init.c res_mkquery.c res_query.c res_send.c \
  780. X    getnetbyaddr.c getnetbyname.c getnetent.c getnetnamadr.c \
  781. X    gethnamaddr.c sethostent.c nsap_addr.c
  782. X
  783. XOBJS=    herror.o res_debug.o \
  784. X    res_comp.o res_init.o res_mkquery.o res_query.o res_send.o \
  785. X    getnetbyaddr.o getnetbyname.o getnetent.o getnetnamadr.o \
  786. X    gethnamaddr.o sethostent.o nsap_addr.o \
  787. X    inet_addr.o strerror.o
  788. X
  789. Xall: libresolv_pic.a
  790. X
  791. X$(OBJS):
  792. X    ${SHCC} ${CFLAGS} ${PIC} -c $? -o $@
  793. X
  794. Xclean: FRC
  795. X    rm -f errs a.out core libresolv_pic.a tags *.o *.BAK *.CKP *~ *.orig
  796. X
  797. Xdepend: 
  798. X    @echo No dependancies in `pwd`
  799. X
  800. Xinstall:
  801. X    @echo '***  shres is *NOT* installed by make install  ***'
  802. X    @echo '*** Read shres/INSTALL for directions ***'
  803. X
  804. XFRC:
  805. X
  806. Xlibresolv_pic.a: ${OBJS}
  807. X    ar cru libresolv_pic.a ${OBJS}
  808. X    $(RANLIB) libresolv_pic.a
  809. X
  810. Xherror.o: ../res/herror.c
  811. Xres_comp.o: ../res/res_comp.c
  812. Xres_debug.o: ../res/res_debug.c
  813. Xres_init.o: ../res/res_init.c
  814. Xres_mkquery.o: ../res/res_mkquery.c
  815. Xres_query.o: ../res/res_query.c
  816. Xres_send.o: ../res/res_send.c
  817. Xgetnetbyaddr.o: ../res/getnetbyaddr.c
  818. Xgetnetbyname.o: ../res/getnetbyname.c
  819. Xgetnetent.o: ../res/getnetent.c
  820. Xgetnetnamadr.o: ../res/getnetnamadr.c
  821. Xgethnamaddr.o: ../res/gethnamaddr.c
  822. Xsethostent.o: ../res/sethostent.c
  823. Xnsap_addr.o: ../res/nsap_addr.c
  824. Xinet_addr.o: ../compat/lib/inet_addr.c
  825. Xstrerror.o: ../compat/lib/strerror.c
  826. END-of-shres/Makefile
  827. echo x - shres/README.NetBSD
  828. sed 's/^X//' >shres/README.NetBSD << 'END-of-shres/README.NetBSD'
  829. X1. makeshlib can now rebuild shared libraries for either SunOS or NetBSD.
  830. X
  831. X2. makeshlib determines the system type automatically by what 'uname' returns.
  832. X   Make sure that 'uname' is in your path.  (Shouldn't be a problem since
  833. X   it's in /usr/bin on both systems)
  834. X
  835. X3. If the script can't find your shared library object files or you haven't
  836. X   built libresolv_pic.a, it will exit immediately, instead of failing on
  837. X   later commands.
  838. X
  839. X4. The shared libraries are rebuilt in the current directory (and uses
  840. X   temporary directories underneath it), instead of in SHLIBDIR.  NetBSD
  841. X   uses /lib for SHLIBDIR, and rebuilding them under /lib did not seem
  842. X   like the appropriate place to do it.
  843. X
  844. X5. You have the option (by setting USELORDER at the top of the script) to
  845. X   dynamically generate an lorder-sparc file using lorder on a SunOS
  846. X   machine.  Using Sun's lorder-sparc file may arguably reduce the
  847. X   amount of paging of the shared library code, and doesn't take as long.
  848. X   On the other hand, since it is generated from the list of object files
  849. X   that are actually present, you don't have to worry too much about the
  850. X   file getting out of order somehow.  NetBSD will always dynamically
  851. X   generate this list, as this is the method it uses when the system shared
  852. X   libraries are built, so unsetting this variable on a NetBSD machine has
  853. X   no effect.
  854. X
  855. X6. Larry Wall's patch program is no longer require to make the modifications
  856. X   to the lorder-sparc file under SunOS if you use it or to the Makefile in 
  857. X   /usr/lib/shlib.etc.  A sed script will modify the lorder-sparc file,
  858. X   and the Makefile is no longer used.
  859. X
  860. END-of-shres/README.NetBSD
  861. echo x - shres/lorder-sparc.sed
  862. sed 's/^X//' >shres/lorder-sparc.sed << 'END-of-shres/lorder-sparc.sed'
  863. X/^gethostent.o/c\
  864. Xgethnamaddr.o\
  865. Xherror.o\
  866. Xsethostent.o\
  867. Xres_query.o\
  868. Xres_mkquery.o\
  869. Xres_send.o\
  870. Xres_debug.o\
  871. Xres_comp.o\
  872. Xres_init.o\
  873. Xgetnetnamadr.o\
  874. Xgetnetbyname.o\
  875. Xgetnetbyaddr.o\
  876. Xstrerror.o\
  877. END-of-shres/lorder-sparc.sed
  878. echo x - shres/makeshlib
  879. sed 's/^X//' >shres/makeshlib << 'END-of-shres/makeshlib'
  880. X#!/bin/sh
  881. X#
  882. X# makeshlib - installs a shareable libresolv_pic.a into SunOS 4.x or NetBSD
  883. X#             1.x libc.so
  884. X#
  885. X# by Chris Davis <ckd@kei.com>
  886. X# based on code by Piete Brooks <pb@cl.cam.ac.uk>
  887. X#              and Dave Morrison <drmorris@mit.edu>
  888. X# NetBSD support added by Matt Ragan <matt@ibmoto.com>
  889. X#
  890. X# $Id: netbsd-shlib.shar,v 8.2 1996/10/25 17:07:58 vixie Exp $
  891. X#
  892. X
  893. X#
  894. X# bindtree should be set to the root directory of the BIND distribution,
  895. X# or you can have this script attempt to determine the location dynamically
  896. X#
  897. X
  898. X#bindtree=/usr/obj/local/bind
  899. X
  900. X#
  901. X# SHLIBDIR should be set to the location of your shared object file
  902. X# (libc_pic.a and/or libcs5_pic.a).  If it is in the default location,
  903. X# they will be found automatically.
  904. X#
  905. X
  906. X#SHLIBDIR=/usr/lib/shlib.etc
  907. X
  908. X#
  909. X# USELORDER will determine whether, under SunOS, that the lorder-sparc
  910. X# file under SHLIBDIR will be user and modified (0), or whether the file
  911. X# will be regenerated dynamically (1).  Purists would say that modifying the
  912. X# lorder-sparc file will reduce paging, but regenerating the file with
  913. X# lorder will do an adequate job of arranging the objects.  Under NetBSD,
  914. X# this option doesn't do anything, since the shared libraries are
  915. X# arranged using lorder when they are built, anyways.
  916. X#
  917. XUSELORDER=0
  918. X
  919. X#
  920. X# END OF USER CONFIGURABLE OPTIONS
  921. X#
  922. X
  923. Xextract_arch () {
  924. X
  925. XARCHIVE=$1
  926. XDIRECTORY=$2
  927. X
  928. X
  929. Xif [ ! -r $SHLIBDIR/$ARCHIVE ]; then
  930. X    echo The shared object archive, $ARCHIVE, does not exist in the
  931. X    echo \$SHLIBDIR directory, $SHLIBDIR, or is not readable.  Please check
  932. X    echo the file and/or path and run this script again.
  933. X    exit 1
  934. Xfi
  935. X
  936. Xif [ ! -d $DIRECTORY ]; then
  937. X    rm -f $DIRECTORY
  938. Xelse
  939. X    echo Cleaning up $DIRECTORY directory
  940. X    rm -rf $DIRECTORY
  941. Xfi
  942. X
  943. Xif mkdir $DIRECTORY; then
  944. X    :
  945. Xelse
  946. X    echo Unable to create the \'$DIRECTORY\' directory under the current directory.
  947. Xfi
  948. X
  949. X#
  950. X# Extract the files to the tmp directory in a subshell
  951. X#
  952. X
  953. X(
  954. Xif cd $DIRECTORY; then
  955. X    :
  956. Xelse
  957. X    echo Unable to change directories to the \'$DIRECTORY\' directory.
  958. X    exit
  959. Xfi
  960. X
  961. Xecho Extracting object files from the shared object archive.
  962. X
  963. Xar x $SHLIBDIR/$ARCHIVE
  964. X
  965. X#
  966. X# Patch up the files and filenames that need patching up.
  967. X#
  968. X
  969. Xif [ $SunOS -eq 1 ]; then
  970. X    for i in *.; do
  971. X        mv $i ${i}o
  972. X    done
  973. Xfi
  974. X
  975. Xecho Deleting old resolver files.
  976. X
  977. Xrm -f $JUNKOBJS
  978. X
  979. X#
  980. X# Extract the shared objects from the BIND distribution
  981. X#
  982. X
  983. Xecho Unpacking new resolver files.
  984. X
  985. Xif [ -f $bindtree/shres/libresolv_pic.a ]; then
  986. X    ar x $bindtree/shres/libresolv_pic.a
  987. X    rm -f __.SYMDEF
  988. Xfi
  989. X)
  990. X
  991. X}
  992. X
  993. Xgenerate_lorder () {
  994. X
  995. Xif [ $SunOS -eq 1 ]; then
  996. X    if [ $USELORDER -eq 0 -a -f $SHLIBDIR/lorder-sparc ]; then
  997. X        sed -f lorder-sparc.sed /usr/lib/shlib.etc/lorder-sparc >lorder.tmp
  998. X        $SHLIBDIR/objsort lorder.tmp $1 > lorder.$1
  999. X        rm -f lorder.tmp
  1000. X    else
  1001. X        lorder $1/*.o | tsort > lorder.$1 2>/dev/null
  1002. X    fi
  1003. Xelif [ $NetBSD -eq 1 ]; then
  1004. X    lorder $1/*.so $1/*.o | tsort > lorder.$1 2>/dev/null
  1005. Xfi
  1006. X}
  1007. X
  1008. XNetBSD=0
  1009. XSunOS=0
  1010. Xif [ `uname -s` = "NetBSD" ]; then
  1011. X    NetBSD=1
  1012. X    JUNKOBJS=gethostnamadr.o
  1013. Xelif [ `uname -s` = "SunOS" ]; then
  1014. X    SunOS=1
  1015. X    JUNKOBJS=gethostent.o
  1016. Xelse
  1017. X    echo "Don't know what OS you are running.  Are you sure it's SunOS or NetBSD?"
  1018. Xfi
  1019. X
  1020. X
  1021. X#
  1022. X# Try to determine where the root of the BIND tree is if $bindtree isn't
  1023. X# set.  First, see if it is one directory above wherever the script is
  1024. X# being run from, then check and see if it is around the current directory
  1025. X# somewhere
  1026. X#
  1027. X
  1028. Xthisdir=`pwd`
  1029. Xcase "x${bindtree}" in
  1030. X
  1031. X'x')
  1032. X    echo 'Attempting to determing BIND tree...'
  1033. X    if [ -d "${thisdir}/shres" ]; then
  1034. X        bindtree=$thisdir
  1035. X    elif [ -d "${thisdir}/../shres" ]; then
  1036. X        bindtree=${thisdir}/..
  1037. X    fi
  1038. X    ;;
  1039. Xesac
  1040. X
  1041. Xcase "x${bindtree}" in
  1042. X'x')
  1043. X    echo "I can't find the bind tree, and you didn't set \$bindtree."
  1044. X    echo "Please do so, and try again."
  1045. X    exit 1
  1046. Xesac
  1047. X
  1048. Xif [ ! -d $bindtree ]; then
  1049. X    echo "Your \$bindtree variable is set incorrectly.  Please correct it"
  1050. X    echo "and run this script again."
  1051. X    exit 1
  1052. Xfi
  1053. X
  1054. Xif [ ! -f $bindtree/shres/libresolv_pic.a ]; then
  1055. X    echo
  1056. X    echo Please build shres/libresolv_pic.a before running this script.
  1057. X    echo See shres/INSTALL for more information.
  1058. X    echo
  1059. X    exit
  1060. Xfi
  1061. X
  1062. X#
  1063. X# Determine the directory to get the shared object archives from, if
  1064. X# $SHLIBDIR is not set
  1065. X#
  1066. X
  1067. Xif [ $SunOS -ne 0 ]; then
  1068. X    SHLIBDIR=${SHLIBDIR-/usr/lib/shlib.etc}
  1069. Xelif [ $NetBSD -ne 0 ]; then
  1070. X    SHLIBDIR=${SHLIBDIR-/usr/lib}
  1071. Xfi
  1072. X
  1073. X#
  1074. X# Extract the UCB libraries on both SunOS and NetBSD
  1075. X#
  1076. X
  1077. Xextract_arch libc_pic.a ucbtmp
  1078. X
  1079. X#
  1080. X# Extract the SYSV libraries on SunOS
  1081. X#
  1082. X
  1083. Xif [ $SunOS -eq 1 ]; then
  1084. X    extract_arch libcs5_pic.a sysvtmp
  1085. Xfi
  1086. X
  1087. X#
  1088. X# Now that we have all of the objects we're going to need, generate an
  1089. X# lorder listing of the objects that we have, or modify the current
  1090. X# lorder-sparc file.
  1091. X#
  1092. X
  1093. Xecho Generating new lorder file for UCB archive
  1094. X
  1095. Xgenerate_lorder ucbtmp
  1096. X
  1097. Xif [ $SunOS -eq 1 ]; then
  1098. X    echo Generating new lorder file for UCB archive
  1099. X    generate_lorder sysvtmp
  1100. Xfi
  1101. X
  1102. XSHLIBNAME=libc.so.`/bin/ls /usr/lib/libc.so.* | awk -f shlibname.awk`
  1103. X
  1104. Xecho Generating new $SHLIBNAME shared library
  1105. X
  1106. Xif [ $SunOS -eq 1 ]; then
  1107. X    ld -o $SHLIBNAME -assert pure-text `cat lorder.ucbtmp` -ldl
  1108. X    SHLIBNAME=libcs5.so.`/bin/ls /usr/lib/libcs5.so.* | awk -f shlibname.awk`
  1109. X    echo Generating new $SHLIBNAME shared library
  1110. X    ld -o $SHLIBNAME -assert pure-text `cat lorder.sysvtmp` -ldl
  1111. Xfi
  1112. X
  1113. Xif [ $NetBSD -eq 1 ]; then
  1114. X    ld -o $SHLIBNAME -Bshareable -Bforcearchive `cat lorder.ucbtmp`
  1115. Xfi
  1116. X
  1117. END-of-shres/makeshlib
  1118. echo x - shres/shlibname.awk
  1119. sed 's/^X//' >shres/shlibname.awk << 'END-of-shres/shlibname.awk'
  1120. XBEGIN {
  1121. X    FS = "."
  1122. X    MAJOR = 0
  1123. X    MINOR = 0
  1124. X    CUSTOM = 0
  1125. X}
  1126. X
  1127. X    {
  1128. X        if ($3 > MAJOR)
  1129. X            MAJOR = $3
  1130. X        if ($4 > MINOR)
  1131. X            MINOR = $4
  1132. X        if ($5 > CUSTOM)
  1133. X            CUSTOM = $5
  1134. X    }
  1135. XEND {
  1136. X    CUSTOM = CUSTOM + 1
  1137. X    printf "%d.%d.%d", MAJOR, MINOR, CUSTOM
  1138. X}
  1139. X        
  1140. END-of-shres/shlibname.awk
  1141. echo x - Makefile.diff
  1142. sed 's/^X//' >Makefile.diff << 'END-of-Makefile.diff'
  1143. X95a96,101
  1144. X> #(NetBSD)
  1145. X> #uncomment next 3 lines to build a shared library version of libresolv
  1146. X> #SHRES = shres
  1147. X> #SHCC = cc
  1148. X> #PIC = -fpic -DPIC -D_res=_res_shlib
  1149. X> 
  1150. END-of-Makefile.diff
  1151. exit
  1152.  
  1153.